@echo off
rem ----------------------------------------
rem Setup C::B root folder of *binaries* (!)
rem ----------------------------------------

set CBSRC=D:\vc\codeblocks\src
cd %CBSRC%

set CB_ROOT=D:\Program Files\CodeBlocks
rem set CB_ROOT=C:\Program Files (x86)\UESoft Studio 1.0

if not defined CB_ROOT set CB_ROOT=D:\Program Files\CodeBlocks

rem ------------------------------------------
rem Setup GCC root folder with "bin" subfolder
rem ------------------------------------------
rem set GCC_ROOT=D:\Program Files\CodeBlocks\MinGW64

rem if not defined GCC_ROOT set GCC_ROOT=%CB_ROOT%\MinGW64
if not defined GCC_ROOT set GCC_ROOT=C:\Qt\Qt5.9.0\Tools\mingw530_32
rem run update.bat after build
rem if not defined CB_RUN_UPDATE_BAT set CB_RUN_UPDATE_BAT=0

rem -------------------------------------------
rem Usually below here no changes are required.
rem -------------------------------------------
if not exist "%CB_ROOT%"  goto ErrNoCB
if not exist "%GCC_ROOT%" goto ErrNoGCC
set PATH=%CB_ROOT%;%GCC_ROOT%;%GCC_ROOT%\bin;%PATH%
set LIBPATH=%GCC_ROOT%\bin;%LIBPATH%


rem 执行命令，大约需要30秒：

mingw32-make -j8 -f %1.workspace.mak clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=1 BUILD=debug clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=1 BUILD=release clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=1 BUILD=debug clean

rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=0 BUILD=release clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=0 BUILD=debug clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=0 BUILD=release clean
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=0 BUILD=debug clean


rem 执行命令，大约需要30分钟，会有20多条警告，忽略之：

mingw32-make -j8 -f %1.workspace.mak all
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=1 BUILD=debug
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=1 BUILD=release
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=1 BUILD=debug

rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=0 BUILD=release
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=1 SHARED=0 BUILD=debug
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=0 BUILD=release
rem mingw32-make -j8 -f %1.workspace.mak UNICODE=1 MONOLITHIC=0 SHARED=0 BUILD=debug


:ErrNoCB
echo Error: C::B root folder not found. Adjust batch file or supply parameter accordingly
goto TheEnd

:ErrNoGCC
echo Error: GCC root folder not found. Adjust batch file or supply parameter accordingly
goto TheEnd

:TheEnd
